package jcf;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapTest {
    public static void main(String[] args) {
        // 校园用户 id = userName
        Map<Integer,String> schoolMap = new HashMap<>();
        schoolMap.put(10,"小张");
        schoolMap.put(11,"小鱼");
        schoolMap.put(12,"小苗");
        System.out.println(schoolMap.put(10,"彭于晏"));
        System.out.println(schoolMap.get(10));
        schoolMap.remove(10);
        // toString
        System.out.println(schoolMap);
        // 迭代 1. Map -> Set
        Set<Map.Entry<Integer,String>> set = schoolMap.entrySet();
        for (Map.Entry<Integer,String> entry : set) {
            System.out.print(entry.getKey());
            System.out.print("=");
            System.out.print(entry.getValue());
            System.out.println();
        }
        System.out.println(schoolMap.get(10));
        System.out.println(schoolMap.get(100));
        System.out.println(schoolMap.getOrDefault(101,
                "zs"));
        System.out.println(schoolMap.containsKey(11));
        System.out.println(schoolMap.containsValue("小鱼"));
    }
}